
module dares.Private;

import dares.Types;

struct	server_state;
alias		ares_channeldata* ares_channel;

const  ARES_QID_TABLE_SIZE		= 2048 ;
const  ARES_TIMEOUT_TABLE_SIZE	= 1024 ;

struct hostent { 
	char*	h_name; 
	char**	h_aliases; 
	int		h_addrtype; 
	int		h_length; 
	char**	h_addr_list; 
}

struct apattern {
	union
	{
		in_addr      	__addr4;
		ares_in6_addr	__addr6;
	} //addr;
	union {
		in_addr		__mask_addr4;
		ares_in6_addr	__mask_addr6;
		c_ushort		__mask_bits ;
	} //mask;
	c_int family;
	c_ushort type;
}


struct rc4_key {
	ubyte state[256];
	ubyte x;
	ubyte y;
} 


struct ares_channeldata {
	c_int		flags;
	c_int		timeout; /* in milliseconds */
	c_int		tries;
	c_int		ndots;
	c_int		rotate; /* if true, all servers specified are used */
	c_int		udp_port;
	c_int		tcp_port;
	c_int		socket_send_buffer_size;
	c_int		socket_receive_buffer_size;
	char**	domains;
	c_int		ndomains;
	apattern*	sortlist;
	c_int		nsort;
	char*	lookups;

	c_int		optmask;

	server_state*	servers;
	c_int			nservers;

	c_ushort		next_id;
	rc4_key		id_key;

	c_int			tcp_connection_generation;

	time_t		last_timeout_processed;

	/* Last server we sent a query to. */
	c_int			last_server;

	list_node		all_queries;
	list_node		queries_by_qid[ARES_QID_TABLE_SIZE];
	list_node		queries_by_timeout[ARES_TIMEOUT_TABLE_SIZE];

	ares_sock_state_cb		sock_state_cb;
	void*		sock_state_cb_data;

	ares_sock_create_callback	sock_create_cb;
	void*		sock_create_cb_data;
}